package com.xdf.wxbebarrel.utils;

import lombok.Getter;
import lombok.ToString;

/**
 * @ClassName:BusinessException
 * @Description:TODO
 * @Author:chanchaw
 * @Date:2019-12-24 8:12
 * @Version:1.0
 **/
@Getter
@ToString
public class BusinessException extends RuntimeException {
    private String msg;
    private JsonResult data;

    public BusinessException(String msg) {
        this.msg = msg;
    }

    public BusinessException(ResultCode rc) {
        this.data = new JsonResult(rc,null);
    }

    public BusinessException(ResultCode rc, Object data) {
        this.data = new JsonResult(rc,data);
    }

    private BusinessException() {
        this.msg = null;
    }

    public static BusinessException instance() {
        return new BusinessException();
    }

    public static BusinessException instance(String msg) {
        return new BusinessException(msg);
    }
}
